package genericdemo;

import sun.plugin2.message.Message;

class Food {

}

class Fruit extends Food{

}

class Apple extends Fruit{

}

class Banana extends Fruit{

}

class Plate<T> {
    private T message;

    public T getPlate() {
        return message;
    }

    public void setPlate(T message) {
        this.message = message;
    }
}

public class TestDemo5 {

    public static void main(String[] args) {
        Plate<Fruit> plate1 = new Plate<>();
        fun(plate1);

        Plate<Food> plate2 = new Plate<>();
        fun(plate2);
    }
    // 通配符下界，传参 Fruit 自己或其父类
    public static void fun(Plate<? super Fruit> temp) {

        temp.setPlate(new Apple());
        temp.setPlate(new Banana());
        // 不可以
        //temp.getPlate(new Food());
    }


    public static void main1(String[] args) {

        Plate<Apple> plate1 = new Plate<>();
        Plate<Banana> plate2 = new Plate<>();

//        fun(plate1);
//        fun(plate2);
    }
    // 通配符上界，只能放它自己或其子类
//    public static void fun(Plate<? extends Fruit> temp) {
//        System.out.println(temp.getPlate());
//    }

}
